import { screenStatistics } from '@/api/screen'

export default function useIndicatorsValueSummaryAndMonitorStatistics() {
  const data = ref({
    comprehensiveEnergyConsumption: '',
    industrialOutput: '',
    energyConsumption: '',
    enterprise: '',
    indicator: '',
    dataCount: '',
  })

  const getIndicatorsValueSummaryAndMonitorStatistics = async () => {
    try {
      const res = await screenStatistics()

      if (res.data) {
        for (const key in res.data) {
          if (res.data[key] != null) {
            res.data[key] = res.data[key]?.toLocaleString()
          }
          else {
            res.data[key] = '-'
          }
        }

        data.value = res.data
      }
    }
    catch (e) {
      console.warn(e)
    }
  }
  return {
    data,
    getIndicatorsValueSummaryAndMonitorStatistics,
  }
}
